//
//  QMASDKDelegateImp.m
//  MiniAppFrameworkDemo
//
//  Created by forrestlin(林福源) on 2019/12/11.
//  Copyright © 2019 Tencent Inc. All rights reserved.
//

#import "QMASDKDelegateImp.h"
#import <QQMiniGameLogin/QQMiniGameLogin.h>
@interface QMASDKDelegateImp ()
@end

@implementation QMASDKDelegateImp

#pragma mark ---------- QMASDKDelegate ----------

/// SDK宿主平台标识、宿主ID、平台ID
/// 小程序平台给第三方平台分配的标识信息
/// 返回的是小写字符串
- (NSString *)getPlatformId {
    //TODO: demo中测试的platform。宿主需要替换
    return @"2039";
}

/// SDK宿主平台的签名信息
/// 用于后台鉴权
/// 二进制的签名信息
- (NSData *)getAppSignatureData {
    //TODO: 宿主需要替换
    return [@"94wanFlagShip" dataUsingEncoding:NSUTF8StringEncoding];

}

/// 获取SDK宿主平台的当前用户账号标识，一般填uin或openid
- (NSString *)getAppUID {
    //TODO: 宿主需要替换
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"hwanQQGameUserId"];
}

#pragma mark - 互联信息根据实际情况填充

/// SDK宿主上的互联openid
- (NSString *)getAppConnectOpenID {
    return [QQMiniGameLoginManager sharedInstance].openID;
}

/// SDK宿主上的互联类型
- (QMAAppConnectType)getAppConnectType {
    if([QQMiniGameLoginManager sharedInstance].loginType == QQMiniGameLoginQQ) {
        return QMAAppConnectTypeQQ;
    }
    else if([QQMiniGameLoginManager sharedInstance].loginType == QQMiniGameLoginWX) {
        return QMAAppConnectTypeWechat;
    }
    return QMAAppConnectTypeInvalid;
}

- (NSString *)getAppConnectAppID {
    return [[QQMiniGameLoginManager sharedInstance] appID];
}
- (NSData *)getAppConnectSessionKey {
    return [[QQMiniGameLoginManager sharedInstance].accessToken dataUsingEncoding:NSUTF8StringEncoding];
}

#pragma mark ---------- QMAAdvDelegate ----------

- (NSString *)amsAppID {
    //TODO: 宿主自行替换
    return @"";
}


@end
